package com.cjm.algorithm.dp;

public class Ti62 {
    public static void main(String[] args) {
        Ti62 ti62 = new Ti62();
        int i = ti62.uniquePaths(3, 7);
        System.err.println("OK");
    }
    public int uniquePaths(int m, int n) {
        int[][] dp = new int[m+1][n+1];
        dp[1][1] = 0;
        dp[1][2] = 1;
        dp[2][1] = 1;
        for (int i = 1; i <= m; i++) {
            for (int j = 1; j <= n; j++) {
                if (i ==1 && j == 1) {
                    continue;
                }
                if (i==1&&j==2) {
                    continue;
                }
                if (i==2&&j==1) {
                    continue;
                }
                if (i== 1&&j>2) {
                    dp[i][j] = dp[i][j - 1];
                } else if (j==1&i>2){
                    dp[i][j] = dp[i - 1][j];
                } else {
                    dp[i][j] = dp[i - 1][j] + dp[i][j-1];
                }
            }
        }
        return dp[m][n];
    }
}
